From 57923b31fa915881cee99d31e088b38506f2d5c6 Mon Sep 17 00:00:00 2001 From: Sam Reed Date: Thu, 24 Feb 2011 18:43:44 +0000 Subject: [PATCH] * (bug 27688) Simplify queries to list user block information Also expose block expiry information, listed on Users, but not all users Some minor simplifications to come --- RELEASE-NOTES | 1 + includes/api/ApiQueryAllUsers.php | 11 +++++------ includes/api/ApiQueryUsers.php | 8 +++----- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index a6322a2cac..52cc00a7d8 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -179,6 +179,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 27554) Update api information text to reflect change in bug 26125 * (bug 27611) list=blocks: Use ipb_by_text instead of join with user table * (bug 27616) Add userid of blocked user and blocker to list=blocks +* (bug 27688) Simplify queries to list user block information === Languages updated in 1.18 === diff --git a/includes/api/ApiQueryAllUsers.php b/includes/api/ApiQueryAllUsers.php index f2979fc2a3..1cdc485c18 100644 --- a/includes/api/ApiQueryAllUsers.php +++ b/includes/api/ApiQueryAllUsers.php @@ -114,12 +114,10 @@ class ApiQueryAllUsers extends ApiQueryBase { if ( $fld_blockinfo ) { $this->addTables( 'ipblocks' ); - $this->addTables( 'user', 'u2' ); - $u2 = $this->getAliasedName( 'user', 'u2' ); $this->addJoinConds( array( 'ipblocks' => array( 'LEFT JOIN', 'ipb_user=u1.user_id' ), - $u2 => array( 'LEFT JOIN', 'ipb_by=u2.user_id' ) ) ); - $this->addFields( array( 'ipb_reason', 'u2.user_name AS blocker_name' ) ); + ) ); + $this->addFields( array( 'ipb_reason', 'ipb_by_text', 'ipb_expiry' ) ); } $this->addOption( 'LIMIT', $sqlLimit ); @@ -181,9 +179,10 @@ class ApiQueryAllUsers extends ApiQueryBase { 'name' => $lastUser, 'userid' => $row->user_id, ); - if ( $fld_blockinfo && !is_null( $row->blocker_name ) ) { - $lastUserData['blockedby'] = $row->blocker_name; + if ( $fld_blockinfo && !is_null( $row->ipb_by_text ) ) { + $lastUserData['blockedby'] = $row->ipb_by_text; $lastUserData['blockreason'] = $row->ipb_reason; + $lastUserData['blockexpiry'] = $row->ipb_expiry; } if ( $fld_editcount ) { $lastUserData['editcount'] = intval( $row->user_editcount ); diff --git a/includes/api/ApiQueryUsers.php b/includes/api/ApiQueryUsers.php index e29394b5ba..7cec1e9120 100644 --- a/includes/api/ApiQueryUsers.php +++ b/includes/api/ApiQueryUsers.php @@ -121,12 +121,10 @@ if ( !defined( 'MEDIAWIKI' ) ) { } if ( isset( $this->prop['blockinfo'] ) ) { $this->addTables( 'ipblocks' ); - $this->addTables( 'user', 'u2' ); - $u2 = $this->getAliasedName( 'user', 'u2' ); $this->addJoinConds( array( 'ipblocks' => array( 'LEFT JOIN', 'ipb_user=u1.user_id' ), - $u2 => array( 'LEFT JOIN', 'ipb_by=u2.user_id' ) ) ); - $this->addFields( array( 'ipb_reason', 'u2.user_name AS blocker_name', 'ipb_expiry' ) ); + ) ); + $this->addFields( array( 'ipb_reason', 'ipb_by_text', 'ipb_expiry' ) ); } $data = array(); @@ -168,7 +166,7 @@ if ( !defined( 'MEDIAWIKI' ) ) { } if ( isset( $this->prop['blockinfo'] ) && !is_null( $row->blocker_name ) ) { - $data[$name]['blockedby'] = $row->blocker_name; + $data[$name]['blockedby'] = $row->ipb_by_text; $data[$name]['blockreason'] = $row->ipb_reason; $data[$name]['blockexpiry'] = $row->ipb_expiry; } -- 2.20.1